<?php

namespace App\Controller;


use App\Base\ErrCode;
use App\Base\Response;
use App\Logic\ArticleLogic;

class Article
{
    use Response;

    /**
     * 文章列表
     */
    public function articleList()
    {
        self::returnJson(...(new ArticleLogic())->getList());
    }

    /**
     * 新增文章
     */
    public function insertArticle()
    {
        self::returnJson(...(new ArticleLogic())->insertArticle());
    }


    /**
     * 参数里面带了数组
     * @OA\Get(
     *     path="/article/test-create-api",
     *     summary="文章列表",
     *     description="我是一个描述",
     *     tags={"article"},
     *     @OA\Parameter(name="userId", in="query", @OA\Schema(type="string"), required=true, description="用户ID"),
     *     @OA\Parameter(name="userName", in="query", @OA\Schema(type="string"), required=true, description="用户姓名"),
     *     @OA\Parameter(name="info", in="query", @OA\Schema(ref="#components/schemas/resBody_data"), required=true, description="基本信息"),
     *     @OA\Response(response=200, description="一个用户列表")
     * )
     *  @OA\Schema(
     *     schema="resBody",
     *     @OA\Property(property="errCode",type="string",description="",example="200"),
     *     @OA\Property(property="data",type="array",description="",@OA\Items(ref="#components/schemas/resBody_data")),
     *     @OA\Property(property="msg",type="string",description="",example="获取列表成功"),
     *  ),
     *  @OA\Schema(
     *     schema="resBody_data",
     *     @OA\Property(property="id",type="integer",description="",example=1),
     *     @OA\Property(property="name",type="string",description="",example="小玲"),
     *     @OA\Property(property="score",description="",ref="#components/schemas/resBody_data_score"),
     *  ),
     *  @OA\Schema(
     *     schema="resBody_data_score",
     *     @OA\Property(property="math",type="integer",description="",example=80),
     *     @OA\Property(property="english",type="integer",description="",example=70),
     *  ),
     *
     */
    public function autoCreateApi()
    {
        self::returnJson(ErrCode::$successCode,[
            [
                "id"=>"1",
                "name"=>"小芳",
                "score"=>[
                    "math"=>80,
                    "english"=>123
                ]
            ],
            [
                "id"=>"2",
                "name"=>"小华",
                "score"=>[
                    "math"=>80,
                    "english"=>123
                ]
            ],
        ],'我是第一个接口的放回msg');
    }


    /**
     * @OA\Get(
     *     path="/article/test-create-api-again",
     *     summary="概要2",
     *     description="我是一个描述22222222",
     *     tags={"article"},
     *     @OA\Parameter(name="userId", in="query", @OA\Schema(type="string"), required=true, description="用户ID"),
     *     @OA\Parameter(name="userName", in="query", @OA\Schema(type="string"), required=true, description="用户姓名"),
     *     @OA\Response(response=200, description="一个用户列表")
     * )
     *
     */
    public function testSwaggerAgain()
    {
        self::returnJson(ErrCode::$successCode,[],'');
    }

}